<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
?>
<div class="admin-model-index">



    <p>
        <?php if (\backend\components\MenuHelper::checkRoute('create')){ echo Html::a('添加管理员', ['create'], ['class' => 'btn btn-success']) ;  } ?>
    </p>
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [

            'username',
            'nickname',
            ['attribute' => 'login_time','value' => function($model) {
                return date('Y-m-d H:i:s',$model->login_time);
            }],
            [
                'attribute'=>'name',
                'value'=>'authRole.name',
                'label'=>'角色名'
            ],
            // 'password_reset_token',
            // 'status',
            // 'password_hash',
            // 'created_at',
            // 'updated_at',
//             'role_id',

            [
                'class' => 'yii\grid\ActionColumn',
                'template' => \backend\components\MenuHelper::filterActionColumn('{update}&nbsp;&nbsp;{delete}'),
                'buttons' => [
                        'delete'=>function($url,$model){
                            if($model->id==Yii::$app->user->id){
                                return null;
                            }
                            return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, ['title' => '删除','data' => [
                                'confirm' => "您确定要删除此项吗？",
                                'method' => 'post',
                            ]]);
                        }
                ]
            ],
        ],
    ]); ?>
</div>
